
"""
导致钻石问题
    子类会调用多次父类的__init__方法，造成资源浪费和重复执行
"""


class Father(object):
    def __init__(self, name):
        self.name = name
        print("I'm father")


class Son1(Father):
    def __init__(self, age,name):
        self.age = age
        Father.__init__(self,name)
        print("I'm Son_1")


class Son2(Father):
    def __init__(self, gender, name):
        self.gender = gender
        Father.__init__(self, name)
        print("I'm Son_2")


class GrandSon(Son1, Son2):
    def __init__(self, name, age, gender):
        Son1.__init__(self, age, name)
        Son2.__init__(self, gender, name)
        print("I'm grandson")
        pass


grand_son = GrandSon("张三", 18, "男")
print(GrandSon.__mro__)  # 获取类的调用顺序

